package com.example.demo2.controller;

import com.example.demo2.bean.Goods;
import com.example.demo2.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin(origins = "*",
        methods = {RequestMethod.GET, RequestMethod.OPTIONS, RequestMethod.POST})
public class GoodsController {
    @Autowired
    GoodsService yourBeanService;

    // 查询一个
    @RequestMapping("/h2/goods/getGoods")
    public Map<String, Object> findone(@RequestBody Goods yourBean) {
        Map<String, Object> map = new HashMap<>();
        Goods yourBean1 = yourBeanService.findone(yourBean);
        if (yourBean1 != null) {
            map.put("success", true);
            map.put("msg", "成功");
            map.put("data", yourBean1);
        } else {
            map.put("success", false);
            map.put("msg", "失败");
        }
        return map;
    }


}

